[][src]Crate num_derive

Procedural macros to derive numeric traits in Rust.

Usage

Add this to your Cargo.toml:

[dependencies]
num-traits = "0.2"
num-derive = "0.2"

Then you can derive traits on your own types:

#[macro_use]
extern crate num_derive;

#[derive(FromPrimitive, ToPrimitive)]
enum Color {
    Red,
    Blue,
    Green,
}

Derive Macros

Float

Derives num_traits::Float for newtypes. The inner type must already implement Float.

FromPrimitive

Derives num_traits::FromPrimitive for simple enums and newtypes.

Num

Derives num_traits::Num for newtypes. The inner type must already implement Num.

NumCast

Derives num_traits::NumCast for newtypes. The inner type must already implement NumCast.

NumOps

Derives num_traits::NumOps for newtypes. The inner type must already implement NumOps.

One

Derives num_traits::One for newtypes. The inner type must already implement One.

ToPrimitive

Derives num_traits::ToPrimitive for simple enums and newtypes.

Zero

Derives num_traits::Zero for newtypes. The inner type must already implement Zero.